<?php
header('Content-Type: application/json');

include 'config.php';

// 查询最新的更新设置
$sql = "SELECT * FROM update_settings ORDER BY id DESC LIMIT 1";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    $row = $result->fetch_assoc();
    echo json_encode([
        'code' => 200,
        'data' => [
            'version' => $row['version'],
            'downloadUrl' => $row['download_url'],
            'updateNotice' => $row['update_notice'],
            'updateType' => $row['update_type']
        ]
    ]);
} else {
    echo json_encode([
        'code' => 404,
        'msg' => '未找到更新设置'
    ]);
}

$conn->close();
?>